package cm.dayo7;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.function.Consumer;

public class Test4 {
    public static void main(String[] args) {
        Set<String>set=new HashSet<>();
        set.add("刘备");
        set.add("关羽");
        set.add("张飞");
        set.add("刘备");
        set.add("张飞");
        System.out.println(set.size());
        System.out.println("..................");
        //迭代器
        Iterator<String>it= set.iterator();
        while (it.hasNext()) {
            String str = it.next();
            System.out.println(str);
        }
        System.out.println("--------------------");
        //增强for
       set.forEach(new Consumer<String>() {
           @Override
           public void accept(String s) {
               System.out.println(s);
           }
       });
    }
}
